Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normalize symmetry in multiplication #14

Merged
merged 1 commit into from
Mar 9, 2023
Merged

Conversation

RyanGlScott
Copy link
Contributor

@RyanGlScott RyanGlScott commented Mar 6, 2023

mul will now flip the order of arguments in mul if it detects that the second argument is a constant, as this can produce more desirable AIGs if the other argument is symbolic. This is part of an eventual fix for GaloisInc/saw-script#1828.

RyanGlScott added a commit to GaloisInc/saw-script that referenced this pull request Mar 6, 2023
This bumps the `aig` submodule to bring in the changes from GaloisInc/aig#14,
which changes how `aig` performs multiplication to swap the order of arguments
if the first argument is a constant. This is because the algorithm that `mul`
uses to compute multiplication is biased in its order of arguments, and having
the second argument be a constant produces a network with more full adders,
which is generally more beneficial.  I have added a test case to check to see
if the test case from #1828 now produces identical AIGs regardless of the order
of arguments.

Fixes #1828.
`mul` will now flip the order of arguments in `mul` if it detects that the
second argument is a constant, as this can produce more desirable AIGs if the
other argument is symbolic. This is part of an eventual fix for
GaloisInc/saw-script#1828.
RyanGlScott added a commit to GaloisInc/saw-script that referenced this pull request Mar 9, 2023
This bumps the `aig` submodule to bring in the changes from GaloisInc/aig#14,
which changes how `aig` performs multiplication to swap the order of arguments
if the second argument is a constant. This has two benefits:

* This ensures that `write_aig` will produce the same networks for `X * C` and
  `C * X`, where `C` is a constant and `X` is a variable.
* The algorithm that `mul` uses to compute multiplication is biased in its order
  of arguments, and having the first argument be a constant tends to produce
  networks that ABC has an easier time verifying. (The FFS example under
  `doc/tutorial/code/ffs.c` is a notable example of this.)

I have added a test case to check to see if the test case from #1828 now
produces identical AIGs regardless of the order of arguments.

Fixes #1828.
@RyanGlScott RyanGlScott merged commit 31da58c into master Mar 9, 2023
@RyanGlScott RyanGlScott deleted the saw-script-T1828 branch March 9, 2023 17:45
RyanGlScott added a commit to GaloisInc/saw-script that referenced this pull request Mar 9, 2023
This bumps the `aig` submodule to bring in the changes from GaloisInc/aig#14,
which changes how `aig` performs multiplication to swap the order of arguments
if the second argument is a constant. This has two benefits:

* This ensures that `write_aig` will produce the same networks for `X * C` and
  `C * X`, where `C` is a constant and `X` is a variable.
* The algorithm that `mul` uses to compute multiplication is biased in its order
  of arguments, and having the first argument be a constant tends to produce
  networks that ABC has an easier time verifying. (The FFS example under
  `doc/tutorial/code/ffs.c` is a notable example of this.)

I have added a test case to check to see if the test case from #1828 now
produces identical AIGs regardless of the order of arguments.

Fixes #1828.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant